<template>
  <div>
  <div>搜索结果：</div>
  <el-row :gutter="24" class="list">
    <el-col :span="3" v-for="advice in search" :key="advice.id">
      <div class="list-item"  @click="getDetail(advice)">
        <img class="imgList" :src="advice.url" alt="暂无"/>
        <h4 style="width: 100px">{{ advice.name }}</h4>
      </div>
    </el-col>
  </el-row>
  </div>
</template>

<script>
export default {
  name: "queryBook",
  data(){
    return{
      search: []
    }
  },
  created() {
    let query = this.$route.query[0];
    this.getBookList(query);
  },
  methods:{
    getDetail(book) {
      this.$router.push({path: "/book/detail", query: {id: book.id}})
    },
    getBookList(bookName) {
      this.$axios.post("/book-message/page", {
        currentPage: 1,
        totalPage: 16,
        name: bookName
      }).then(res => {
        if (res.data.code === '200') {
          this.search = res.data.data;
        } else {
          this.$message.error(res.data.message);
        }
      })
    }
  }
}
</script>

<style scoped>
.imgList {
  width: 90px;
  height: 110px;
}
.list {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  text-align: center;
  flex-wrap: wrap;
  min-height: 200px;
  width: 100%;
}
.list-item {
  padding-top: 20px;
  width: 150px;
  display: flex;
  justify-content: flex-start;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
</style>
